package com.coder520.user.service;
import com.coder520.commom.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.coder520.user.entity.User;
import com.coder520.user.dao.UserMapper;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

/**
 * @Author 高鑫【gx_wanmei@163.com】
 * Created by 2017-6-19.2:34
 */
@Service("userServiceImp")
public class UserServiceImp implements  UserService {
    @Autowired
    private  UserMapper userMapper;
    /**
     *@Author JackGao [gx_wanmei@163.com]
     *@Date 2017-6-21 19:06
     *@Description  根据用户名查询用户
     */
    @Override
    public User findUserByUserName(String username) {
        User user=userMapper.selectByUserName(username);
        return user;
    }

    @Override
    public void createUser(User user) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        user.setPassword(SecurityUtils.encrptyPassword(user.getPassword()));
        userMapper.insertSelective(user);
    }
}
